package vues;

import java.awt.EventQueue;

import javax.swing.JFrame;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;

import modele.map.MapParser;
import modele.map.TypeTerrain;

import java.awt.GridLayout;

public class CouleurMapWindow extends JFrame{
	private List<Color> couleurs;
	JPanel panel, panelCouleurs, panelBoutons;
	JButton valider;
	/**
	 * Create the application.
	 */
	public CouleurMapWindow(List<Color> couleurs) {
		this.couleurs = couleurs;
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		this.panel = new JPanel();
		this.panel.setLayout(new BorderLayout());
		this.setBounds(100, 100, 1000, 930);
		this.setTitle("Assignation Terrain / Couleur");
		JScrollPane scrollPane = new JScrollPane();
		panelCouleurs = new JPanel();
		panelCouleurs.setLayout(new GridLayout(couleurs.size(), 2, 0, 0));
		panelBoutons = new JPanel();
		valider = new JButton("Valider");
		this.panelBoutons.add(valider);
		
		for(Color c : couleurs){
			System.out.println(c);
			JPanel jp = new JPanel();
			jp.setBackground(c);
			this.panelCouleurs.add(jp);
			this.panelCouleurs.add(new JComboBox<TypeTerrain>(TypeTerrain.values()));
		}

		
		scrollPane.setViewportView(panelCouleurs);
		
		
		this.panel.add(scrollPane, BorderLayout.CENTER);
		this.panel.add(panelBoutons, BorderLayout.SOUTH);
		this.setContentPane(panel);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
	}
}
